package com.pason.onlineshop.mainshop.util;

import static com.pason.onlineshop.mainshop.util.ShopConstants.SYSTEM_ENVIRONMENT_NAME;

public class EnvironmentUtil {
	
	/** The DEV PREFIX . */
    public static String ENV_DEV_PREFIX = "dev_";

    /** The PROD prefix. */
    public static String ENV_PROD_PREFIX = "";
    
    /**
     * Returns true when in dev or Bamboo CI server environment otherwise false
     * 
     * @return
     */
    public static boolean isDevEnv() {
        return (EnvironmentUtil.getEnvironmentName().equalsIgnoreCase(EnvironmentUtil.ENV_DEV_PREFIX));
    }
    
    /**
     * Gets the environment name prefix e.g. DEV_
     * 
     * @return the environment name
     */
    public static String getEnvironmentName() {
        String envValue = System.getenv(SYSTEM_ENVIRONMENT_NAME);
        if (envValue == null) {
            envValue = ENV_PROD_PREFIX;
        }
        return System.getProperty(SYSTEM_ENVIRONMENT_NAME, envValue);
    }
    
    /**
     * Gets the http port number e.g. 7301
     * 
     * @return the http port number
     */
    public static Integer getHttpPort() {
        return new Integer(System.getProperty("jetty.http.port", "8080"));
    }
    
    /**
     * Gets the webdriver type eg HTMLUNIT
     * 
     * @return the webdriver type
     */
    public static String getWebDriverType() {
        return System.getProperty("webdriver.type", "");
    }
    
    /**
     * Gets the build type type eg HTMLUNIT
     * 
     * @return the webdriver type
     */
    public static String getBuildType() {
        return System.getProperty("build.type", "");
    }
    
    public static String getHostName() {
        return System.getProperty("host.name", "localhost");
    }
}
